package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.ScreenStandardControllerDTO;
import com.hzeport.bgs22emduty.vo.ScreenStandard.ScreenStandSortVO;
import com.hzeport.bgs22emduty.vo.ScreenStandard.ScreenStandardsaveVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.entity.ScreenStandard;
import com.hzeport.bgs22emduty.service.ScreenStandardService;
//import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * ${comments}
 *
 * @author code generator
 * @date 2023-02-14 09:39:44
 */

@RestController
@AllArgsConstructor
@RequestMapping("/screenstandard")
@Api(value = "screenstandard", tags = "000值班规范管理")
@Slf4j
public class ScreenStandardController {

    private final ScreenStandardService screenStandardService;

    private final LoginCompoentService loginCompoentService;

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public   BaseResult<Page<ScreenStandard>> list(@RequestBody ScreenStandardControllerDTO dto) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenStandardService.list(dto,userInfoDetailVO);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @OperLog( systemName = "ZBGF", description = "GFSC")
    public BaseResult removeById(@RequestParam("id") String id) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return screenStandardService.delete(id,userInfoDetailVO);
    }

    @ApiOperation(value = "保存")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    @OperLog( systemName = "ZBGF", description = "GFBC")
    public BaseResult save(@RequestBody ScreenStandardsaveVO screenStandardsaveVO) throws Exception {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  screenStandardService.saveData(screenStandardsaveVO,userInfoDetailVO);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<ScreenStandardsaveVO> detail(@RequestParam("id") String id){
        return screenStandardService.detail(id);
    }

    @ApiOperation(value = "序号排序")
    @RequestMapping(value = "saveSort",method = RequestMethod.POST)
    @OperLog( systemName = "ZBGF", description = "GFPX")
    public BaseResult updatesort(@RequestBody ScreenStandSortVO screenStandardSort)  {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return screenStandardService.saveSort(screenStandardSort,userInfoDetailVO);
    }

}
